package com.jintoufs.weixin.commodity;

import com.jintoufs.service.commodity.CommodityService;
import org.cosmos.modules.web.msg.AjaxMsg;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/commodity")
public class CommodityAction {
    @Resource
    private CommodityService commodityService;
    @GetMapping("/list")
    public AjaxMsg list(String type,String keyWord,String orderType,String isDesc, String regionName,Integer pageSize,Integer pageNum,boolean selfSupport){
        AjaxMsg ajaxMsg = new AjaxMsg();
        Map<String,Object> params = new HashMap<>();
        params.put("pageStart",(pageNum-1)*pageSize);
        params.put("pageSize", pageSize);
        params.put("regionName", regionName);
        params.put("selfSupport", selfSupport);
        params.put("keyWord", keyWord);
        params.put("orderType", orderType);
        params.put("isDesc", isDesc);
        params.put("type", type);
        List<Map<String, Object>> tourList = commodityService.getByParams(params);

        ajaxMsg.setDatas(tourList);
        return ajaxMsg;
    }
}
